package com.lm.chronicle.producer;

import net.openhft.chronicle.queue.ChronicleQueue;
import net.openhft.chronicle.queue.ExcerptAppender;

public class CustomObjectProducer {
    public static void main(String[] args) {
        // 创建一个 Chronicle Queue 队列，存储路径为 "./data/queue"
        try (ChronicleQueue queue = ChronicleQueue.single("./data/queue")) {
            ExcerptAppender appender = queue.acquireAppender();

            // 写入 10 条消息
            for (int i = 1; i <= 10; i++) {
                String message = "Message " + i;
                appender.writeDocument(w -> w.write("data").text(message));
                System.out.println("Produced: " + message);
            }
        }
    }
}
